package ru.ksu.ktk.diploma.sdi.bean;

import ru.ksu.ktk.diploma.sdi.session.DescriptionList;

import javax.el.ValueExpression;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.faces.context.FacesContext;
import javax.faces.application.Application;

/**
 * Created by IntelliJ IDEA.
 * User: coldflame
 * Date: 21.12.2008
 * Time: 21:22:37
 * To change this template use File | Settings | File Templates.
 */
public class WelcomeBean {
    public String viewIntegration() {
        createDescriptionList();
        return "integration";
    }
    public String viewSearch() {
        return "search";
    }

    /**
     * create session parameter for store user's description file list
     */
    private void createDescriptionList() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application application = facesContext.getApplication();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory ELfactory = application.getExpressionFactory();
        ValueExpression valueExpression = ELfactory.createValueExpression(elContext,
                "#{sessionScope.descriptionList}",
                ValueExpression.class);
        valueExpression.setValue(elContext, new DescriptionList());
    }
}
